package com.vince.servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.vince.model.domain.DiscountOrderItem;
import com.vince.model.domain.Order;
import com.vince.model.domain.OrderItem;
import com.vince.model.domain.PromotionOrderItem;
import com.vince.util.DBUtil;
@WebServlet("/servlet/itemsservlet")
public class ItemsServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		//订单详情的处理逻辑
		List<OrderItem> itemsorder=new ArrayList<>();
		String method=req.getParameter("method");
		
		
		if("list".equals(method)){
			String orderid=req.getParameter("orderid");
			String sql1="select order_id,order_code,buyer,sum,delivery_method,last_modify_date,"
					+ "created_date from torder where order_id=?";
			DBUtil mysql=new DBUtil();
			Connection conn=null;
			try {
				conn=mysql.getConnection();
				PreparedStatement ps=conn.prepareStatement(sql1);
				ps.setInt(1, Integer.valueOf(orderid));
				ResultSet rs=ps.executeQuery();
				Order order=new Order();
				if(rs.next()){
					order.setOrderId(rs.getInt(1));
					order.setOrderCode(rs.getString(2));
					order.setBuyer(rs.getString(3));
					order.setSum(rs.getDouble(4));
					order.setDeliveryMethod(rs.getString(5));
					order.setLastModifyDate(rs.getDate(6));
					order.setCreateddate(rs.getDate(7));
					
				}
				req.setAttribute("order", order);
				
				
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			String sql2="select item_id,name,discount_type,unit_num,"
					+ "unit_price,sum,order_id from itemsorder where order_id=?";
			List<OrderItem> itemlist=new ArrayList<OrderItem>();

			try {
				PreparedStatement ps2=conn.prepareStatement(sql2);
				ps2.setInt(1, Integer.valueOf(orderid));
				ResultSet rs2=ps2.executeQuery();
				while(rs2.next()){
				
					OrderItem itemorder=new OrderItem();
					itemorder.setItemid(rs2.getInt(1));
					itemorder.setName(rs2.getString(2));
					itemorder.setDiscountType(rs2.getInt(3));
					itemorder.setUnitNum(rs2.getInt(4));
					itemorder.setUnitPrice(rs2.getDouble(5));
					itemorder.setSum(rs2.getDouble(6));
					itemorder.setOrderId(rs2.getInt(7));
					itemlist.add(itemorder);
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			req.setAttribute("itemlist", itemlist);
			req.getRequestDispatcher("/view/orders/orderItemManage/itemlist.jsp").forward(req, resp);
			
		}else if("delete".equals(method)){
			//删除该订单详情
			//1.删除该订单详情，2.更新torder的sum值，3.停留在订单详情页
			String itemid=req.getParameter("itemid");
			String sum=req.getParameter("sum");
			String orderid=req.getParameter("orderid");
			String sql="delete from itemsorder where item_id=?";
			DBUtil mysql=new DBUtil();
			Connection conn1 = null;
			PreparedStatement ps = null;
			try {
				conn1=mysql.getConnection();
				ps=conn1.prepareStatement(sql);
				ps.setInt(1, Integer.valueOf(itemid));
				ps.executeUpdate();
				
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}finally{
				mysql.releaseResource(conn1, ps, null);
			}
			
			Connection conn2 = null;
			String sql2="select sum(sum) from itemsorder where order_id=?";
			Connection conn;
			Double ordersum=null;
			try {
				conn = mysql.getConnection();
				PreparedStatement ps2=conn.prepareStatement(sql2);
				ps2.setInt(1, Integer.valueOf(orderid));
				ResultSet rs2=ps2.executeQuery();
				if(rs2.next()){
					ordersum=rs2.getDouble(1);
				}

			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			
			String sql3="update torder set sum=? where order_id=? ";
			PreparedStatement ps3=null;
			try {
				conn2 = mysql.getConnection();
				ps3=conn2.prepareStatement(sql3);
				ps3.setDouble(1,ordersum );
				ps3.setInt(2, Integer.valueOf(orderid));
				ps3.executeUpdate();
				

			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}finally{
			}
			req.getRequestDispatcher("/servlet/itemsservlet?method=list&orderid="+orderid).forward(req, resp);
			
			
			
			
		}else if("update".equals(method)){
			 //1，更新该订单详情记录,2，修改torder的sum值，3，停留在modifyitem.jsp

			String itemid=req.getParameter("itemid");
			String orderid=req.getParameter("orderid");
			String itemname=req.getParameter("itemname");
			String discounttype=req.getParameter("discounttype");
			String unitnum=req.getParameter("unitnum");
			String unitprice=req.getParameter("unitprice");
			String sum=req.getParameter("sum");
			//做对象封装
			System.out.println("itemname:"+itemname+"discounttype="+discounttype+"unitnum="+unitnum+"unitprice="+unitprice+"sum"+sum+"orderid="+orderid);

			 DBUtil mysql=new DBUtil();

			if("1".equals(discounttype)){
				System.out.println("进入1.......");
				OrderItem orderitem=new OrderItem();
				orderitem.setName(itemname);
				orderitem.setDiscountType(Integer.valueOf(discounttype));
				orderitem.setUnitNum(Integer.valueOf(unitnum));
				orderitem.setUnitPrice(Double.valueOf(unitprice));
				orderitem.setSum(Double.valueOf(sum));
				orderitem.setOrderId(Integer.valueOf(orderid));
				orderitem.setItemid(Integer.valueOf(itemid));
				//
				String sql1="update itemsorder set name=?,discount_type=?,unit_num=?,unit_price=?,sum=?,order_id=?,discount=NULL,promotion_price=NULL,promotion_num=NULL where item_id=?";
				try {
					Connection conn=mysql.getConnection();
					PreparedStatement ps=conn.prepareStatement(sql1);
					ps.setString(1,orderitem.getName());
					ps.setInt(2, orderitem.getDiscountType());
					ps.setInt(3, orderitem.getUnitNum());
					ps.setDouble(4, orderitem.getUnitPrice());
					ps.setDouble(5, orderitem.getSum());
					ps.setInt(6, orderitem.getOrderId());
					ps.setInt(7, orderitem.getItemid());
					ps.execute();
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				String sql2="select sum(sum) as s from itemsorder where order_id=?";
				String sql3="update torder set sum=? where order_id=?";
				Double ordersum = null;
				try {
					Connection conn=mysql.getConnection();
					PreparedStatement ps2=conn.prepareStatement(sql2);
					ps2.setInt(1,Integer.valueOf(orderid));
					ResultSet rs=ps2.executeQuery();
					if(rs.next()){
						ordersum=rs.getDouble("s");
					}
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}finally{
					
				}
				
				PreparedStatement ps3=null;
				Connection conn;
				try {
					conn = mysql.getConnection();
					ps3=conn.prepareStatement(sql3);
					ps3.setDouble(1, ordersum);
					ps3.setInt(2, Integer.valueOf(orderid));
					ps3.executeUpdate();
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}finally{
					
				}
				
			}else if("2".equals(discounttype)){
			
				String discount=req.getParameter("discount");
				DiscountOrderItem discountItem=new DiscountOrderItem();
				discountItem.setName(itemname);
				discountItem.setDiscountType(Integer.valueOf(discounttype));
				discountItem.setUnitNum(Integer.valueOf(unitnum));
				discountItem.setUnitPrice(Double.valueOf(unitprice));
				discountItem.setSum(Double.valueOf(sum));
				discountItem.setOrderId(Integer.valueOf(orderid));
				discountItem.setDiscount(Double.valueOf(discount));
				discountItem.setItemid(Integer.valueOf(itemid));
				String sql1="update itemsorder set name=?,discount_type=?,unit_num=?,unit_price=?,sum=?,order_id=?,"
						+ "discount=?,promotion_price=NULL,promotion_num=NULL where item_id=?";
				
				try {
					Connection conn=mysql.getConnection();
					PreparedStatement ps2=conn.prepareStatement(sql1);
					ps2.setString(1,discountItem.getName());
					ps2.setInt(2, discountItem.getDiscountType());
					ps2.setInt(3, discountItem.getUnitNum());
					ps2.setDouble(4, discountItem.getUnitPrice());
					ps2.setDouble(5, discountItem.getSum());
					ps2.setInt(6, discountItem.getOrderId());
					ps2.setDouble(7, discountItem.getDiscount());
					ps2.setInt(8, discountItem.getItemid());
					ps2.executeUpdate();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				String sql2="select sum(sum) as s from itemsorder where order_id=?";
				String sql3="update torder set sum=? where order_id=?";
				Double ordersum = null;
				try {
					Connection conn=mysql.getConnection();
					PreparedStatement ps2=conn.prepareStatement(sql2);
					ps2.setInt(1,Integer.valueOf(orderid));
					ResultSet rs=ps2.executeQuery();
					if(rs.next()){
						ordersum=rs.getDouble("s");
					}
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}finally{
					
				}
				
				PreparedStatement ps3=null;
				Connection conn;
				try {
					conn = mysql.getConnection();
					ps3=conn.prepareStatement(sql3);
					ps3.setDouble(1, ordersum);
					ps3.setInt(2, Integer.valueOf(orderid));
					ps3.executeUpdate();
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}finally{
					
				}
			}else if("3".equals(discounttype)){
				String promotionprice =req.getParameter("promotionprice");
				String promotionnum=req.getParameter("promotionnum");
				PromotionOrderItem promotionItem=new PromotionOrderItem();
				promotionItem.setName(itemname);
				promotionItem.setDiscountType(Integer.valueOf(discounttype));
				promotionItem.setUnitNum(Integer.valueOf(unitnum));
				promotionItem.setUnitPrice(Double.valueOf(unitprice));
				promotionItem.setSum(Double.valueOf(sum));
				promotionItem.setOrderId(Integer.valueOf(orderid));
				promotionItem.setPromotionNum(Integer.valueOf(promotionnum));
				promotionItem.setPromotionPrice(Double.valueOf(promotionprice));
				promotionItem.setItemid(Integer.valueOf(itemid));
				
				String sql1="update itemsorder set name=?,discount_type=?,unit_num=?,unit_price=?,sum=?,order_id=?,"
						+ "promotion_price=?, promotion_num=?,discount=NULL where item_id=?";
				try {
					Connection conn=mysql.getConnection();
					PreparedStatement ps=conn.prepareStatement(sql1);
					ps.setString(1,promotionItem.getName());
					ps.setInt(2, promotionItem.getDiscountType());
					ps.setInt(3, promotionItem.getUnitNum());
					ps.setDouble(4, promotionItem.getUnitPrice());
					ps.setDouble(5, promotionItem.getSum());
					ps.setInt(6, promotionItem.getOrderId());
					ps.setDouble(7, promotionItem.getPromotionPrice());
					ps.setInt(8, promotionItem.getPromotionNum());
					ps.setInt(9, promotionItem.getItemid());
					ps.execute();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				String sql2="select sum(sum) as s from itemsorder where order_id=?";
				String sql3="update torder set sum=? where order_id=?";
				Double ordersum = null;
				try {
					Connection conn=mysql.getConnection();
					PreparedStatement ps2=conn.prepareStatement(sql2);
					ps2.setInt(1,Integer.valueOf(orderid));
					ResultSet rs=ps2.executeQuery();
					if(rs.next()){
						ordersum=rs.getDouble("s");
					}
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}finally{
					
				}
				
				PreparedStatement ps3=null;
				Connection conn;
				try {
					conn = mysql.getConnection();
					ps3=conn.prepareStatement(sql3);
					ps3.setDouble(1, ordersum);
					ps3.setInt(2, Integer.valueOf(orderid));
					ps3.executeUpdate();
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}finally{
					
				}
			}
			
			/**
			 * 更新torder的总金额
			 */

			//更新toder的总金额
			String sql2="select sum(sum) as s from itemsorder where order_id=?";
			String sql3="update torder set sum=? where order_id=?";
			Double ordersum = null;
			try {
				Connection conn=mysql.getConnection();
				PreparedStatement ps2=conn.prepareStatement(sql2);
				ps2.setInt(1,Integer.valueOf(orderid));
				ResultSet rs=ps2.executeQuery();
				if(rs.next()){
					ordersum=rs.getDouble("s");
				}
				
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}finally{
				
			}
			PreparedStatement ps3=null;
			Connection conn;
			try {
				conn = mysql.getConnection();
				ps3=conn.prepareStatement(sql3);
				ps3.setDouble(1, ordersum);
				ps3.setInt(2, Integer.valueOf(orderid));
				ps3.executeUpdate();
				
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			//跳转到itemlist.jsp进行显示
			req.getRequestDispatcher("/servlet/itemsservlet?method=list&orderid="+orderid).forward(req, resp);//转发
			
		}else if("add".equals(method)){
			//增加明细到明细表
			System.out.println("进入add items 功能");
			List<OrderItem> itemlist=new ArrayList<OrderItem>();
			String discounttype=req.getParameter("discounttype");
			String itemname=req.getParameter("itemname");
			String unitnum=req.getParameter("unitnum");
			String unitprice=req.getParameter("unitprice");
			String sum=req.getParameter("sum");
			String orderid=req.getParameter("orderid");
			System.out.println("itemname:"+itemname+"discounttype="+discounttype+"unitnum="+unitnum+"unitprice="+unitprice+"sum"+sum+"orderid="+orderid);

			if("1".equals(discounttype)){
				System.out.println("进入1.......");
				OrderItem orderitem=new OrderItem();
				orderitem.setName(itemname);
				orderitem.setDiscountType(Integer.valueOf(discounttype));
				orderitem.setUnitNum(Integer.valueOf(unitnum));
				orderitem.setUnitPrice(Double.valueOf(unitprice));
				orderitem.setSum(Double.valueOf(sum));
				orderitem.setOrderId(Integer.valueOf(orderid));
				String sql1="insert into itemsorder(name,discount_type,unit_num,unit_price,"
						+ "sum,order_id) values(?,?,?,?,?,?)";
				DBUtil mysql=new DBUtil();
				Connection conn=null;
				PreparedStatement ps = null;

				try {
					conn=mysql.getConnection();
					ps=conn.prepareStatement(sql1);
					ps.setString(1, orderitem.getName());
					ps.setInt(2, orderitem.getDiscountType());
					ps.setInt(3, orderitem.getUnitNum());
					ps.setDouble(4, orderitem.getUnitPrice());
					ps.setDouble(5, orderitem.getSum());
					ps.setInt(6, orderitem.getOrderId());
					Integer rs=ps.executeUpdate();
					if(rs==1){
						System.out.println("...............插入成功");
					}
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
					
				}finally{
					mysql.releaseResource(conn, ps, null);
				}
				
			}else if("2".equals(discounttype)){
			
				String discount=req.getParameter("discount");
				DiscountOrderItem discountItem=new DiscountOrderItem();
				discountItem.setName(itemname);
				discountItem.setDiscountType(Integer.valueOf(discounttype));
				discountItem.setUnitNum(Integer.valueOf(unitnum));
				discountItem.setUnitPrice(Double.valueOf(unitprice));
				discountItem.setSum(Double.valueOf(sum));
				discountItem.setOrderId(Integer.valueOf(orderid));
				discountItem.setDiscount(Double.valueOf(discount));
				String sql2="insert into itemsorder(name,discount_type,unit_num,unit_price,"
						+ "sum,order_id,discount) values(?,?,?,?,?,?,?)";
				DBUtil mysql=new DBUtil();
				Connection conn = null;
				PreparedStatement ps2=null;

				try {
					conn = mysql.getConnection();
					ps2=conn.prepareStatement(sql2);
					ps2.setString(1, discountItem.getName());
					ps2.setInt(2, discountItem.getDiscountType());
					ps2.setInt(3, discountItem.getUnitNum());
					ps2.setDouble(4, discountItem.getUnitPrice());
					ps2.setDouble(5, discountItem.getSum());
					ps2.setInt(6, discountItem.getOrderId());
					ps2.setDouble(7, discountItem.getDiscount());
					Integer rs2=ps2.executeUpdate();
					if(rs2==1){
						System.out.println("discountItem插入成功");
						
					}
										
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}finally{
					mysql.releaseResource(conn, ps2, null);
				}

				
			}else if("3".equals(discounttype)){
				String promotionprice =req.getParameter("promotionprice");
				String promotionnum=req.getParameter("promotionnum");
				PromotionOrderItem promotionItem=new PromotionOrderItem();
				promotionItem.setName(itemname);
				promotionItem.setDiscountType(Integer.valueOf(discounttype));
				promotionItem.setUnitNum(Integer.valueOf(unitnum));
				promotionItem.setUnitPrice(Double.valueOf(unitprice));
				promotionItem.setSum(Double.valueOf(sum));
				promotionItem.setOrderId(Integer.valueOf(orderid));
				promotionItem.setPromotionNum(Integer.valueOf(promotionnum));
				promotionItem.setPromotionPrice(Double.valueOf(promotionprice));
				String sql3="insert into itemsorder(name,discount_type,unit_num,unit_price,"
						+ "sum,order_id,promotion_price,promotion_num) values(?,?,?,?,?,?,?,?)";
				DBUtil mysql=new DBUtil();
				Connection conn=null;
				PreparedStatement ps3 = null;

				try {
					conn = mysql.getConnection();
					ps3=conn.prepareStatement(sql3);
					ps3.setString(1, promotionItem.getName());
					ps3.setInt(2, promotionItem.getDiscountType());
					ps3.setInt(3, promotionItem.getUnitNum());
					ps3.setDouble(4, promotionItem.getUnitPrice());
					ps3.setDouble(5, promotionItem.getSum());
					ps3.setInt(6, promotionItem.getOrderId());
					ps3.setDouble(7, promotionItem.getPromotionPrice());
					ps3.setInt(8,promotionItem.getPromotionNum());
					Integer rs3=ps3.executeUpdate();
					if(rs3==1){
						System.out.println("promotionItem插入成功...........");
					}
					
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}finally{
					mysql.releaseResource(conn, ps3, null);
				}
				
			}
			
			//更新toder的总金额
			String sql2="select sum(sum) as s from itemsorder where order_id=?";
			String sql3="update torder set sum=? where order_id=?";
			DBUtil mysql=new DBUtil();
			Double ordersum = null;
			try {
				Connection conn=mysql.getConnection();
				PreparedStatement ps2=conn.prepareStatement(sql2);
				ps2.setInt(1,Integer.valueOf(orderid));
				ResultSet rs=ps2.executeQuery();
				if(rs.next()){
					ordersum=rs.getDouble("s");
				}
				
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}finally{
				
			}
			PreparedStatement ps3=null;
			Connection conn;
			try {
				conn = mysql.getConnection();
				ps3=conn.prepareStatement(sql3);
				ps3.setDouble(1, ordersum);
				ps3.setInt(2, Integer.valueOf(orderid));
				ps3.executeUpdate();
				
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			req.getRequestDispatcher("/view/orders/orderItemManage/itemadd.jsp?orderid="+String.valueOf(orderid)).forward(req, resp);
	
		}else if("view".equals(method)){
			//根据itemid查出该订单详情，封装成对象，传递到modifyitem.jsp,跳转到modifyitem.jsp页面显示
			
			String itemid=req.getParameter("itemid");
			String discounttype=req.getParameter("discounttype");
			DBUtil mysql=new DBUtil();
			if("1".equals(discounttype)){
				OrderItem item=new OrderItem();
				String sql="select item_id, name,discount_type, unit_num, unit_price,"
						+ "sum,order_id from itemsorder where item_id=?";
				Connection conn;
				try {
					conn = mysql.getConnection();
					PreparedStatement ps=conn.prepareStatement(sql);
					ps.setInt(1, Integer.valueOf(itemid));
					ResultSet rs=ps.executeQuery();
					if(rs.next()){
						item.setItemid(rs.getInt(1));
						item.setName(rs.getString(2));
						item.setDiscountType(rs.getInt(3));
						item.setUnitNum(rs.getInt(4));
						item.setUnitPrice(rs.getDouble(5));
						item.setSum(rs.getDouble(6));
						item.setOrderId(rs.getInt(7));
	
					}
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				req.setAttribute("itemobj", item);
				

				
			}else if("2".equals(discounttype)){
				DiscountOrderItem discountitem=new DiscountOrderItem();
				String sql="select item_id, name,discount_type, unit_num, unit_price,"
						+ "sum,order_id, discount from itemsorder where item_id=?";
				Connection conn;
				try {
					conn = mysql.getConnection();
					PreparedStatement ps=conn.prepareStatement(sql);
					ps.setInt(1, Integer.valueOf(itemid));
					ResultSet rs=ps.executeQuery();
					if(rs.next()){
						discountitem.setItemid(rs.getInt(1));
						discountitem.setName(rs.getString(2));
						discountitem.setDiscountType(rs.getInt(3));
						discountitem.setUnitNum(rs.getInt(4));
						discountitem.setUnitPrice(rs.getDouble(5));
						discountitem.setSum(rs.getDouble(6));
						discountitem.setOrderId(rs.getInt(7));
						discountitem.setDiscount(rs.getDouble(8));
					}
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				req.setAttribute("itemobj", discountitem);				
				
				
			}else if("3".equals(discounttype)){
				PromotionOrderItem promotionitem=new PromotionOrderItem();
				String sql="select item_id, name,discount_type, unit_num, unit_price,"
						+ "sum,order_id,promotion_price, promotion_num  from itemsorder where item_id=?";
				try {
					Connection conn=mysql.getConnection();
					PreparedStatement ps=conn.prepareStatement(sql);
					ps.setInt(1, Integer.valueOf(itemid));
					ResultSet rs=ps.executeQuery();
					if(rs.next()){
						promotionitem.setItemid(rs.getInt(1));
						promotionitem.setName(rs.getString(2));
						promotionitem.setDiscountType(rs.getInt(3));
						promotionitem.setUnitNum(rs.getInt(4));
						promotionitem.setUnitPrice(rs.getDouble(5));
						promotionitem.setSum(rs.getDouble(6));
						promotionitem.setOrderId(rs.getInt(7));
						promotionitem.setPromotionPrice(rs.getDouble(8));
						promotionitem.setPromotionNum(rs.getInt(9));

					}
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				req.setAttribute("itemobj", promotionitem);
				
			}
			req.getRequestDispatcher("/view/orders/orderItemManage/modifyitem.jsp").forward(req, resp);
			
		}
		
		
		
	}
	
	

}
